def count_chars_in_window(s, window_size):
    """
    滑动窗口统计字符出现次数：返回每个窗口内各字符的计数
    s：目标字符串
    window_size：窗口大小
    """
    from collections import deque, defaultdict
    queue = deque()
    result = []
    char_count = defaultdict(int)
    for char in s:
        queue.append(char)
        char_count[char] += 1
        # 窗口超过大小时，移除队首字符并更新计数
        if len(queue) > window_size:
            removed_char = queue.popleft()
            char_count[removed_char] -= 1
            if char_count[removed_char] == 0:
                del char_count[removed_char]
        # 窗口大小达到要求时，记录当前计数
        if len(queue) == window_size:
            result.append(dict(char_count))
    return result

# 测试
print(count_chars_in_window("aababcabc", 3))
# 输出：[{'a': 2, 'b': 1}, {'a': 1, 'b': 2}, {'b': 2, 'c': 1}, {'a': 1, 'b': 1, 'c': 2}, {'b': 1, 'c': 2, 'a': 1}, {'c': 2, 'a': 1, 'b': 1}]